package com.io.computer_practice_sjlx;
import java.io.*;
//ʹ��BufferedReader��BufferedWriter �滻�ı��ļ����� (��д�ı��ļ�) 
public class Replace {
	public static void main(String[] args) {
		String line=null;
		FileReader fr=null;
		FileWriter fw = null;
		BufferedReader br=null;
		BufferedWriter bw = null;
		StringBuffer sb=null;
		try{
			sb=new StringBuffer();
			//1.��������������, �����ȡ�ı��ļ�
			 fr = new FileReader("C:\\���.txt");
			 br = new BufferedReader(fr);
			//2.�������������, �����ļ�����д�뵽ָ���ı��ļ���(���ļ�ĩβ׷��)
			 fw = new FileWriter("D:\\���.txt");
			 bw = new BufferedWriter(fw);
			//3.ѭ����ȡ��׷���ַ�
			while( (line = br.readLine() ) != null ){
				sb.append(line);
			}
			System.out.println("�滻ǰ:"+sb);
			/*�滻����*/
			String newString = sb.toString().replace("{name}" , "����");
			newString = newString.replace("{strain}", "���ӵľ��鹫��");
			//�����滻�������
			System.out.println("�滻��:"+newString);
			fw.write(newString);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
				try {
						bw.close();
						fw.close();//�ر��ļ������
				} catch (FileNotFoundException e) {//�����쳣
						e.printStackTrace();
				} catch (IOException e) {
						e.printStackTrace();
				}
		}
	}
}
